package com.wc.codeforces.前缀和与差分.前缀和.Sort;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/7/27 17:18
 * @description https://codeforces.com/contest/1996/problem/C
 */
public class Main {
    /**
     * 思路：
     * 计数 + 前缀和
     * 一段范围内的每个字母的数量之差 / 2
     * 那是不是就可以想到前缀和, 求一段范围内的和(数量和)
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[][] a = new int[N][26];
    static int[][] b = new int[N][26];
    static char[] s;
    static int n, q;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            for (int i = 1; i <= n; i++) {
                Arrays.fill(a[i], 0);
                Arrays.fill(b[i], 0);
            }
            n = sc.nextInt();
            q = sc.nextInt();
            s = (" " + sc.next()).toCharArray();
            for (int i = 1; i <= n; i++) {
                a[i][s[i] - 'a']++;
                for (int j = 0; j < 26; j++) a[i][j] += a[i - 1][j];
            }
            s = (" " + sc.next()).toCharArray();
            for (int i = 1; i <= n; i++) {
                b[i][s[i] - 'a']++;
                for (int j = 0; j < 26; j++) b[i][j] += b[i - 1][j];
            }
            while (q-- > 0) {
                int l = sc.nextInt(), r = sc.nextInt();
                int res = 0;
                for (int i = 0; i < 26; i++) {
                    // 每一个字母的数
                    int v1 = a[r][i] - a[l - 1][i], v2 = b[r][i] - b[l - 1][i];
                    res += Math.abs(v1 - v2);
                }
                out.println(res / 2);
            }
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
